<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box1 {
            width: 200px;
            height: 200px;
            background-color: antiquewhite;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .class_box1 {
            display: block;
            width: 100%;
            height: 100px;
            background-color: cornflowerblue;
        }

        .input_box1_class {
            display: block;
        }
    </style>
</head>

<body>

    <div id="box1">
        <div class="class_box1">
            <input type="text" name="input_box1" id="input_box1" class="input_box1_class">
            <textarea name="" id="textarea111" cols="30" rows="10"></textarea>
            <p name="" id="textarea">
                <text id="textarea222"></text>
            </p>
        </div>
    </div>

    <script src="../../js/jquery.3.5.1.js"></script>
    <script src="../js05-监听Dom更改.js"></script>
    <script>
        $("#input_box1").change(()=> $("#textarea222").text($("#input_box1").val()))

        // 监听属性的更改
        // var observer = mutation(document.getElementById("textarea111"));
        // observer.setFnClass(function(tag, old, mutation){
        //     console.log('tag, old, mutation', tag, old, mutation);
        // })
        
        // 监听元素的删除和添加
        // var observer = mutation(document.getElementById("box1"));
        // observer.setFnChildList(function(tag, old, mutation){
        //     console.log('tag, old, mutation', tag, old, mutation);
        // })

        
        // 文本内容的更改
        var observer3 = mutation(document.getElementById("textarea222"));
        observer3.setSubtree(false)
        // observer3.setAttributeFilter(['value'])
        observer3.setCharacterData(true)
        observer3.setCharacterDataOldValue(true)
        
        
        // var observer = mutation('document.getElementById("textarea")');
        
    </script>
</body>

</html>